layout.tsx 706 B

12345678910111213141516171819202122232425262728293031
  1. import './style.scss';
  2. import { ReactNode } from 'react';
  3. import { notFound } from 'next/navigation';
  4. import { fetchUserProfile } from '@/lib/api/account/profile';
  5. import UserProfileHeader from './_component/UserProfileHeader';
  6. type Props = {
  7. children: ReactNode;
  8. params: Promise<{ sid: string }>;
  9. };
  10. export default async function UserProfileLayout({ children, params }: Props)
  11. {
  12. const { sid } = await params;
  13. const res = await fetchUserProfile(sid);
  14. if (!res.success || !res.data) {
  15. notFound();
  16. }
  17. const profile = res.data;
  18. return (
  19. <div className="user-profile">
  20. <UserProfileHeader profile={profile} />
  21. <div className="user-profile__content">
  22. {children}
  23. </div>
  24. </div>
  25. );
  26. }